package cn.ahaoweb.drule.core.listener;

import cn.ahaoweb.drule.core.FactInfo;
import org.kie.api.event.rule.AfterMatchFiredEvent;
import org.kie.api.event.rule.BeforeMatchFiredEvent;
import org.kie.api.event.rule.MatchCancelledEvent;
import org.kie.api.event.rule.MatchCreatedEvent;

/**
 * @Name: FiredRuleExecuteListener
 * @Description:
 * @Author: wangzhonghao
 * @Date: 2025/2/13 18:57
 */
public class FiredRuleExecuteListener implements RuleExecuteListener{

    public static final FiredRuleExecuteListener DEFAULT = new FiredRuleExecuteListener();

    @Override
    public void matchConditionCancelled(MatchCancelledEvent event, FactInfo factInfo) {

    }

    @Override
    public void matchConditionStart(MatchCreatedEvent event, FactInfo factInfo) {

    }

    @Override
    public void beforeFireRule(BeforeMatchFiredEvent event, FactInfo factInfo) {

    }

    @Override
    public void afterFireRule(AfterMatchFiredEvent event, FactInfo factInfo) {
        // 记录命中的规则
        factInfo.addFiredRule(event.getMatch().getRule().getName());
    }

    @Override
    public boolean singleton() {
        return false;
    }

}
